package tmproject.hlhj.fhp.cartrans.adapter

import android.content.Intent
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import tmproject.hlhj.fhp.cartrans.R
import tmproject.hlhj.fhp.cartrans.activitys.ExamRuleAty
import tmproject.hlhj.fhp.cartrans.javaBean.ExamListBean
import tmproject.hlhj.fhp.cartrans.log
import tmproject.hlhj.fhp.cartrans.utils.SpHelper

/**
 * Created by Never Fear   on 2018\8\28 0028.
Never More....
 */
class ExamFgmListAdp(private val datas:ArrayList<ExamListBean.DataBean.ListBean>)
    :BaseQuickAdapter<ExamListBean.DataBean.ListBean,BaseViewHolder>(R.layout.fgm_exam_item,datas) {
    var listener:LearnListAdp.JumpListener?=null
    override fun convert(helper: BaseViewHolder?, item: ExamListBean.DataBean.ListBean?) {
        helper?.setText(R.id.itemTittle,item?.name)
        helper?.setText(R.id.itemTime,"截至时间：${item?.end_date}")

        when(item?.status){
            "NS"->{
                if (SpHelper.getExam(mContext,item?.id)==null){
                    log("fhp","是否为空")
                    helper?.setText(R.id.itemState,"未答卷")
                }else{
                    log("fhp","是否为空2")
                    helper?.setText(R.id.itemState,"进度${SpHelper.getExam(mContext,item?.id)?.nowIndex} / ${item?.question_num}")
                }
                helper?.itemView?.setOnClickListener {
                    val intent = Intent(mContext, ExamRuleAty::class.java)
                    intent.putExtra("id",datas[helper?.adapterPosition].id)
                    listener?.jump(intent)
//                    mContext!!.startActivity(intent)
                }
            }
            "ST"->{
                helper?.itemView?.setOnClickListener {

                }
                helper?.setText(R.id.itemState,"已终止")
            }
            "CP"->{
                helper?.itemView?.setOnClickListener {

                }
                helper?.setText(R.id.itemState,"${item?.score}分")

            }
        }
    }
}